import 'package:flutter/material.dart';

import 'package:xunlongchi/util/app_util.dart';
import 'package:xunlongchi/util/data_util.dart';

///方位
class Position extends StatelessWidget {
  const Position({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final List<Widget> _item = Iterable<int>.generate(4)
        .map((i) => RotationTransition(
              turns: AlwaysStoppedAnimation(-45 * i / 360 - 0.5),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  RotatedBox(
                    quarterTurns: -1,
                    child: Text(
                        '${DataUtil.pos[i + 4]}\n${DataUtil.bagua[i + 4]}'),
                  ),
                  RotatedBox(
                    quarterTurns: 1,
                    child: Text('${DataUtil.pos[i]}\n${DataUtil.bagua[i]}'),
                  ),
                ],
              ),
            ))
        .toList();

    final double _posSize = 480.px;

    return DefaultTextStyle(
      textAlign: TextAlign.center,
      style: TextStyle(
        color: Colors.white,
        fontWeight: FontWeight.bold,
        fontSize: 34.sp,
      ),
      child: SizedBox(
        width: _posSize,
        height: _posSize,
        child: Stack(
          alignment: Alignment.center,
          children: _item,
        ),
      ),
    );
  }
}
